home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM BV3 / BMUG PD-ROM Version BV3 (CDRM1097900).iso / Telecom / Compacting Programs / MacBin / MacBinary Standard < prev   
Text File  |  1989-03-27  |  12KB  |  234 lines

  1. Macintosh Binary Transfer Format ("MacBinary") Standard Proposal
  2. ----------------------------------------------------------------
  3.  
  4. Dennis F. Brothers - 13 March 1985
  5. (Revision 1 - 10 April 1985 - Miscellaneous clarifications)
  6. (Revision 2 - 12 April 1985 - Corrected reversal of icon position v,h)
  7. (Revision 3 -  6 May   1985 - Added processor ID, general cleanup)
  8.   
  9.  
  10. The following notes are a proposal for a standard format for binary transfer
  11. of arbitrary Macintosh documents via a telecommunication link. It is intended
  12. for use both between Macintoshes running (possibly different) terminal
  13. programs which adhere to the standard, and for use in uploading arbitrary
  14. Macintosh documents to remote systems (where it is presumed that they will be
  15. stored as an exact image of the data transmitted). A proposal is also made for
  16. standard processing to be performed on text files transferred via a protocol,
  17. to maximize the likelihood that text files transmitted to a remote system will
  18. be usable by that system, and that text files received from a remote system
  19. will be usable by the Macintosh.
  20.  
  21. It is recommended that the format and procedures described here be referred
  22. to as "MacBinary", and that any terminal program implementing this format
  23. and procedures be called "MacBinary-Compatible".
  24.  
  25. The binary format described is independent of the communication protocol used
  26. to accomplish the transfer, and assumes only that an 8-bit transparent
  27. transfer can be accomplished. Such protocols as Christensen (usually referred
  28. to as XMODEM or MODEM7), Kermit, and CompuServe A or B meet this requirement.
  29. Because of the proposed standard's MacTerminal/XMODEM heritage, there is a
  30. requirement that the transmitted data be padded (with nulls) to a 128-byte
  31. boundary at certain points, but this in no way implies that a block-oriented
  32. protocol must be used. The basic format proposed is identical to that used by
  33. MacTerminal, by Mike Boich and Martin Haeberli, and can be used with a version
  34. of MacTerminal that has had a patch applied to "normalize" its implementation
  35. of the XMODEM protocol. 
  36.  
  37. In brief, the binary format consists of a 128-byte header containing all the
  38. information necessary to reproduce the document's directory entry on the
  39. receiving Macintosh; followed by the document's Data Fork (if it has one),
  40. padded with nulls to a multiple of 128 bytes (if necessary); followed by the
  41. document's Resource Fork (again, padded if necessary). The lengths of these
  42. forks (either or both of which may be zero) are contained in the header. 
  43.  
  44. The format of the 128-byte header is as follows (offsets and lengths are given
  45. in decimal):  
  46.  
  47.         Offset   Length   Contents
  48.         ------   ------   --------
  49.         000      1        Zero. This is a "version" byte.
  50.         001      1        Length of filename.
  51.         002      63       Filename (only "length" bytes are significant).
  52.        (the following 16 bytes are a standard Finder Info record)
  53.         065      4        File type.
  54.         069      4        File creator.
  55.         073      1        Finder flags:
  56.                                  Bit 7 - Locked.
  57.                                  Bit 6 - Invisible.
  58.                                  Bit 5 - Bundle.
  59.                                  Bit 4 - System.
  60.                                  Bit 3 - Bozo.
  61.                                  Bit 2 - Busy.
  62.                                  Bit 1 - Changed.
  63.                                  Bit 0 - Inited.
  64.         074      1        Zero.
  65.         075      2        File's vertical position within its window.
  66.         077      2        File's horizontal position within its window.
  67.         079      2        File's window or folder ID.
  68.        (End of Finder Info)
  69.         081      1        "Protected" flag (in low order bit).
  70.         082      1        Zero.
  71.         083      4        Data Fork length (bytes, zero if no Data Fork).
  72.         087      4        Resource Fork lenth (bytes, zero if no R.F.).
  73.         091      4        File's creation date.
  74.         095      4        File's "last modified" date.
  75.         099      27       Zero fill (reserved for expansion of standard).
  76.     126      2        Reserved for computer type and OS ID
  77.                           (this field will be zero for the current Macintosh).
  78.  
  79. Note that it is the responsibility of the receiving terminal program to
  80. resolve file name conflicts, generally by somehow modifying the name of
  81. received file if there already exists a file with the original name on the
  82. target volume.
  83.  
  84. Note also that, while the original window or folder ID and position may be
  85. transmitted, the receiving terminal program would not normally set these items
  86. for the received file, but would instead accept the values that the File
  87. Manager assigns when it creates the new file.
  88.  
  89. It is suggested that Macintosh terminal programs implement two modes of
  90. protocol transfer: text and document. Text mode is used for unformatted files
  91. of type TEXT (with only a data fork), and document mode (using the binary
  92. format proposed here) is used for all other files. Document mode may also be
  93. used on text files, of course, if it is desired to preserve such things as the
  94. file's creator ID or creation date.
  95.  
  96. The intent of text mode is to provide compatibility with text files on other
  97. systems. Toward that end, it is recommended that a linefeed be inserted after
  98. each return character as the text file is transmitted, and that, in the case
  99. of block-oriented protocols, the last block be explicitely padded with nulls
  100. if the text does not end on a block boundary. When receiving in text mode,
  101. linefeeds and trailing nulls should be stripped. If a CTRL-Z (Hex 1A) character
  102. is received following all other text (and before any null padding), it should
  103. also be stripped (Ctrl-Z is a common text terminator on CP/M and smoe other
  104. systems). Note that the above discussion applies only to text files transferred
  105. under some protocol, where an exact image of the transmitted data will be
  106. stored in a file on the remote system.
  107.  
  108. When receiving a file via a protocol, a terminal program may distinguish
  109. between text and document modes by examining bytes 0, 74, and 82 of the first
  110. 128 bytes received. If they are each zero (and at least 128 bytes have been
  111. received), then it is a safe assumption that a MacBinary-formatted document
  112. is being received. Terminal programs implementing possible future versions of
  113. the proposed standard would, of course, accept an appropriate set of version
  114. numbers in byte 0. Note also that compatible extensions of Version 0 of the
  115. proposed standard are possible (one such is suggested below) that involve
  116. transmission of additional information following the information described here.
  117. For this reason, a terminal program should be implemented so as to perform
  118. the proper receive procedures for all data sent to it, but to ignore any data
  119. that it does not know what to do with.
  120.  
  121. Since a text-mode document does not contain a file name, it is suggested that
  122. when text-mode is detected, a file be opened under a dummy name on the
  123. receiving Macintosh, the text written to that file, and the file renamed to a
  124. name selected by the user (via an SFPutFile box) after the reception is
  125. completed. This will avoid problems caused by indeterminate delays for name
  126. selection at the beginning of the file transfer.
  127.  
  128. It is desirable to allow the user to specify the destination volume in advance
  129. of the actual start of transfer for either type of transfer. Two methods are
  130. suggested for this: provide a "Select Destination Volume" menu selection,
  131. presumably in the menu containing the "Receive File" selection; or query the
  132. user immediately after the "Receive File" menu selection is made. Either or
  133. both of these methods could be implemented in a given terminal program - the
  134. independent "Select Receive Volume" method is particularly desirable if the
  135. ESC-a/ESC-b automatic receive facility (see below) is implemented. The volume
  136. selection procedure should provide the same functions as the volume selection
  137. portion of the SFGetFile and SFPutFile dialog boxes.
  138.  
  139.  
  140. First proposed extension to the proposed standard:
  141. --------------------------------------------------
  142.  
  143. It is proposed that the binary format described above be extended to allow the
  144. transmission of descriptive text with a Macintosh document (specifically, the
  145. descriptive text from the Finder's "Get Info" box for the file being
  146. transferred). This is to be accomplished in a transparent manner by assigning
  147. bytes 99 and 100 of the header described above to be used to hold the length
  148. of the descriptive text (or zero, if there is none). The descriptive text, if
  149. any, will begin on the 128-boundary immediately following the Resource Fork,
  150. if present, else the Data Fork, if present, else immediately following the
  151. header if neither fork is present. It is hoped that methods for reading and
  152. setting a file's "Get Info" text will be made public at some point.
  153.  
  154.  
  155. Notes on MacTerminal's XMODEM implementation, and a proposed extension:
  156. -----------------------------------------------------------------------
  157.  
  158. Familiarity with the Christensen (XMODEM) protocol is assumed in the following
  159. discussion.
  160.  
  161. When doing "Mac-to-Mac" transfers, using the binary format described above,
  162. unmodified MacTerminal does not use a true XMODEM protocol, and is therefore
  163. incompatible with most non-Mac systems. The differences lie in two specifics:
  164. the transmitting Macintosh initiates the transfer by sending the the two
  165. characters ESCAPE (hex 1B) and "a" (hex 61); the receiving Macintosh is
  166. expected to reply with the character ACK (hex 06). The transfer then proceeds
  167. using normal XMODEM procedures, except that each of the header and the two
  168. forks (if present) is treated as a separate XMODEM transfer, with the
  169. transmitting Macintosh waiting for a NAK (hex 15), then sending the blocks of
  170. that phase (beginning with a block number of one), then sending EOT (hex 04)
  171. and waiting for an ACK (hex 06) from the receiving Macintosh.
  172.  
  173. It is proposed that a modified procedure be accepted as a standard, to be
  174. implemented instead of or in addition to the above-described MacTerminal
  175. "Mac-to-Mac" protocol in complying terminal programs. The modified procedure,
  176. which is compatible with standard XMODEM implementations, functions as
  177. follows: The transmitting Macintosh sends the two characters ESCAPE (hex 1B)
  178. and "b" (hex 62). The receiving Macintosh may optionally reply with ACK (hex
  179. 06) (this is allowed so as to have minimum impact on existing
  180. MacTerminal-compatible implementations). The transmitting Macintosh then
  181. awaits receipt of a NAK (hex 15) (or optionally a "C" (hex 43), if the
  182. receiving terminal program supports CRC checking), following which a single,
  183. normal XMODEM transfer occurs. The transfer may be in text mode or document
  184. mode, will begin with block number one, and block numbers will increment
  185. uniformly (modulo 256) throughout the transfer.
  186.  
  187. It is expected that a patch to MacTerminal making it compatible with the above
  188. proposed procedure will be available in the near future.
  189.  
  190.  
  191. Responses to proposals:
  192. -----------------------
  193.  
  194. Please address comments or questions on the above proposals to:
  195.  
  196.         Dennis F. Brothers
  197.         197 Old Connecticut Path
  198.         Wayland, MA 01778
  199.     617-358-2863
  200.  
  201.         CompuServe: 70065,172
  202.         Delphi:     DBROTHERS
  203.         MCI Mail:   DBROTHERS
  204.  
  205.  
  206.  
  207. MacBinary Working Group:
  208. ------------------------
  209.  
  210. An informal working group, consisting of Macintosh terminal program developers
  211. and others with interests or expertise in the field of computer communications,
  212. was formed during April, 1985 to discuss and refine this proposal. The group
  213. met in the MAUG (Micro-networked Apple User's Group) Special Interest Group on
  214. the CompuServe Information Service. The present form of the MacBinary format
  215. standard represents a consensus of this group as a whole, but may not reflect
  216. the opinion of a given individual member of the group.
  217.  
  218. The working group included:
  219.    Christopher Allen
  220.    William Bond
  221.    Steve Brecher
  222.    Dennis Brothers
  223.    Ward Christensen
  224.    Dan Cochran
  225.    Mike Cohen
  226.    Bill Cook
  227.    Ed Edell
  228.    Duane Harris
  229.    Yves Lempereur
  230.    Neil Shapiro
  231.    Dan Smith
  232.    Bill Steinberg
  233.    Scott Watson